import request from '@/utils/request'
// import qs from 'qs'

// arp表

// 获取arp列表
export function getArpArray (params) {
  var data = fromData(params)
  return request({
    url: 'arp/getArpArray',
    method: 'post',
    data
  })
}

// 清空arp列表
export function cleanArp (params) {
  var data = fromData(params)
  return request({
    url: 'arp/clean_arp',
    method: 'post',
    data
  })
}

// 增加信息
export function addArp (params) {
  var data = fromData(params)
  return request({
    url: 'arp/addInfo',
    method: 'post',
    data
  })
}

// 删除信息
export function delArp (params) {
  var data = fromData(params)
  return request({
    url: 'arp/del_info',
    method: 'post',
    data
  })
}

// 修改信息
export function editArp (params) {
  var data = fromData(params)
  return request({
    url: 'arp/editInfo',
    method: 'post',
    data
  })
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
